Suggested Multiplayer Weapons-Handling Script. Version 8.
July 12, 2004.

By Dirk Mittler
Email: mdirk@sympatico.ca

This script is available FREE, and may also be modified by the receiving author, to suit your own needs. Its designed to replace the existing weapons.wdl script in the include files directly.

You will not need to mention my name under any circumstances, commercial or whatever, because my main aim is to contribute and to share.

What's new in v4: Key 'D' drops weapon back into game for other players.
                  Key '0' now deselects weapon safely, to allow handling
                  other objects without shooting.

What's new in v5: It's possible to pick up weapons by using mouse again,
                  even in multiplayer games.

What's new in v6: Bug Fix. Earlier 'Q' and 'E' commands (instead of number keys)
                  used to switch other players' weapons (corrected).

What's new in v7: If you use the startgun1 or gun_givePlayer actions for your server level,
                  which automatically give the gun to the player, these functions will
                  work as well as possible in multiplayer.

                  NOTE: This gun will find a player who materializes within 120 quants                   immediately at start of game. When a game is started in -sv -cl.

                  gun_givePlayer now calls gun_pickup() to do its work.

What's new in v8: In case a multiplayer game entity wants to reward a player by arming
                  him with a weapon, this will work again without the weapon attaching
                  itself to the othetr entity.

I apologize for not documenting my work better. I kept the comments from Conitec, some of which are no longer actual. The idea is that gun_pickup will set the owner of the weapon and then call on gun_select to select it. gun_select will always test if the entity owns the weapon before selecting it.

There are two entity skills which must belong to the player, which are named

_ARM and _ARMED .

Because I defined those in the movement.wdl file, I did not put those skills into this file, and you will need to DEFINE them yourself as well. Such as

DEFINE _ARM,SKILL33;
DEFINE _ARMED,SKILL34;

Further, to help cope with game restarts, I suggest you (optionally) place my._ARMED = 0 into the beginning of your own player actions. And to help a weapon find the person who's clicking it, even if distracted by non-player entities,

you should modify item_pickup() to set 

my.enable_detect = on;

in doors.wdl (optionally).

If you enable EVENT_DETECT in some other gun action, it will not be re-enabled after you drop the weapon back into the level, after which other, non-player entities may make it impossible to pick up again, BUT ONLY FOR MOUSE-CLICK.

Enjoy.
Dirk

